//
//  CardView.swift
//  codelabs
//
//  Created by 雷雷 on 25/05/2025.
//

import SwiftUI
import SwiftData

struct CardView: View {
    let scrum:DailyScrum
    
    var body: some View {
        VStack(alignment:.leading){
            Text(scrum.title)
                .font(.title3)
                .bold()
                .accessibilityAddTraits(.isHeader)
            Spacer()
            HStack{
                Label("\(scrum.attendees.count)",systemImage: "person.3")
                    .accessibilityLabel("\(scrum.attendees.count) attendees")
                Spacer()
                Label("\(scrum.lengthInMinutes)",systemImage: "clock")
                    .labelStyle(.trailingIcon)
                    .accessibilityLabel("\(scrum.lengthInMinutes) minute meeting")
            }
            .padding(.trailing)
            .font(.caption)
        }
        .padding()
        .foregroundColor(scrum.theme.accentColor)
        
    }
}

#Preview(traits: .dailyScrumSampleData,  .fixedLayout(width:480,height:60)){
    @Previewable @Query(sort:\DailyScrum.title) var scrums:[DailyScrum]
    
    CardView(scrum:scrums[0])
        .background(scrums[0].theme.mainColor)
    
}
